/**
 * 
 */
package com.witframework.meta;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.javalid.annotations.core.JvMethod;
import org.javalid.annotations.helper.Lookup;
import org.javalid.annotations.helper.SpringLookup;
import org.javalid.annotations.validation.LovConstraint;
import org.javalid.annotations.validation.MaxLength;
import org.javalid.annotations.validation.MaxValue;
import org.javalid.annotations.validation.MinValue;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;

import com.witframework.core.annotations.Wit;
import com.witframework.core.structure.BaseWitObject;

/**
 * @author wuxinyang Jun 5, 2009 3:38:10 PM
 */

@Entity @Table(name="Meta_Table_Column") @Wit(cnname = "表的列的元数据",cnproperty="displayName")
public class MetaTableColumn extends BaseWitObject{
	
	@NotNull @Length(max=32) @Wit(cnname="索引名称", description="用于引用数据的简单名称")
	private String simpleName;//系统会自动产生的
	
	// 基本信息
	@Column(length = 127)@Wit(cnname = "列名称", description = "列的名称")
	private String columName;// 属性的名称
	
	@Column(length = 100)@Wit(cnname = "显示名称",description = " 列的显示名称")
	private String displayName;		
	
	
	@Column(length=255) @MaxLength(length=255)@Wit(cnname="说明")
    String description;	
	
	@Wit(cnname = "长度", description = "列长度(默认值255)")
	private int columnSize;
	
	@Column(length = 100)@Wit(cnname = "类型名称",description = "列的类型名称")
	private String typeName;	
	
	@Wit(cnname = "精度", description = "列十进制精度(decimal precision)")
	private int precision_length;
	
	@Wit(cnname = "范围", description = "是十进制数值范围,如果列十进制数值范围(decimal scale)可用,在此设置(默认值0)")
	private int scale;
	
	@Column(length = 100)@Wit(cnname = "缺省值",description = "列的缺省值")
	private String columnDef;	
	
	@Column(length = 1)@Wit(cnname = "标识?", description = "该列是否为实体bean的标识属性列")
	private String isIdentity = "N";
	
	@Column(length = 1)@Wit(cnname = "唯一?", description = "是否在该列上设置唯一约束")
	private String isUnique = "N";
	
	@Column(length = 1)@Wit(cnname = "可空?", description = "是否设置该列的值可以为空")
	private String isNullable = "Y";	
	
	
	
	@Column(length = 1)@Wit(description = "是否在列表页面显示")
	private String viewInList;
	
	@Column(length = 1)@Wit(description = "是否作为过滤项")
	private String asFilter;
	
	@MaxValue(10000000) @MinValue(-10000000)@Wit(cnname="顺序",description="顺序值")
	private int sortnum;
	
	
	@ManyToOne@LazyToOne(LazyToOneOption.FALSE)	
	@LovConstraint (
    dynamic=true,
    lookup=@Lookup(type=Lookup.LOOKUP_SPRING_BEAN,springLookup=@SpringLookup(name="metaTableService",method=@JvMethod(name="getAll")))
	)
	private MetaTable metaTable;

	public String getColumName() {
		return columName;
	}

	public void setColumName(String columName) {
		this.columName = columName;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public int getColumnSize() {
		return columnSize;
	}

	public void setColumnSize(int columnSize) {
		this.columnSize = columnSize;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public int getPrecision() {
		return precision_length;
	}

	public void setPrecision(int precision) {
		this.precision_length = precision;
	}

	public int getScale() {
		return scale;
	}

	public void setScale(int scale) {
		this.scale = scale;
	}

	public String getColumnDef() {
		return columnDef;
	}

	public void setColumnDef(String columnDef) {
		this.columnDef = columnDef;
	}

	public String getIsIdentity() {
		return isIdentity;
	}

	public void setIsIdentity(String isIdentity) {
		this.isIdentity = isIdentity;
	}

	public String getIsUnique() {
		return isUnique;
	}

	public void setIsUnique(String isUnique) {
		this.isUnique = isUnique;
	}

	public String getIsNullable() {
		return isNullable;
	}

	public void setIsNullable(String isNullable) {
		this.isNullable = isNullable;
	}

	public MetaTable getMetaTable() {
		return metaTable;
	}

	public void setMetaTable(MetaTable metaTable) {
		this.metaTable = metaTable;
	}

	public String getSimpleName() {
		return simpleName;
	}

	public void setSimpleName(String simpleName) {
		this.simpleName = simpleName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getViewInList() {
		return viewInList;
	}

	public void setViewInList(String viewInList) {
		this.viewInList = viewInList;
	}

	public String getAsFilter() {
		return asFilter;
	}

	public void setAsFilter(String asFilter) {
		this.asFilter = asFilter;
	}

	public int getSortnum() {
		return sortnum;
	}

	public void setSortnum(int sortnum) {
		this.sortnum = sortnum;
	}

	
	
}
